﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using OpenSoftStore.BusinessLogic.Bill;
using OpenSoftStore.BusinessLogic.Member;
using OpenSoftStore.Client.Common;

namespace OpenSoftStore.Client.UIL.ManageReport
{
    public partial class ReportValueRecord : UserControl
    {

        private MemberValueRecordLogic LgcMemberValueRecord;
        private static ReportValueRecord instance;
        public static ReportValueRecord Instance
        {
            get
            {
                if (instance == null)
                {
                    instance = new ReportValueRecord();
                }
                return instance;
            }
        }
        public ReportValueRecord()
        {
            LgcMemberValueRecord = new MemberValueRecordLogic();
            InitializeComponent();
            dtpFrom.Value = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd") + " 00:00:00");
            dtpTo.Value = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd") + " 23:59:59");
            this.Dock = DockStyle.Fill;
            dgvBill.AutoGenerateColumns = false;
            dgvBill.DataSource = LgcMemberValueRecord.GetMemberValueRecordDataTable("  where T_MemberValueRecord.AddTime=#" + DateTime.Now.Date + "# ");
            SPACommon.SetDataGridStyle(dgvBill);
            SPACommon.ShowSummary(dgvBill);
        }

        private void btnSearch_Click(object sender, EventArgs e)
        {
            DateTime from = dtpFrom.Value.Date;
            DateTime to = dtpTo.Value.Date;
            string whereStr = string.Format(" where T_MemberValueRecord.AddTime between #{0}# and #{1}#  ", from, to);
            dgvBill.DataSource = LgcMemberValueRecord.GetMemberValueRecordDataTable(whereStr);
        }

        private void btnOutput_Click(object sender, EventArgs e)
        {
            SPACommon.ExportToExcel(dgvBill, "客户充值统计");
        }
    }
}
